clear all
set more off

**** GLOBALS *****;
global 	InputFile ${dat}\HSV_repdata.dta
global 	OutputDir ${res}
global straps  500
*********************;


use ${InputFile} , clear

//levels of pre and postgov inc
gen pregovinc = max(redpregovinc - tot_deduction + 0.5*fica,0)
gen dispinc = max(reddispinc - tot_deduction + 0.5*fica + hwdpvpengain1,0)


//logs of pre and postgov inc
replace lpregovinc = log(redpregovinc - tot_deduction + 0.5*fica)
replace ldispinc = log(reddispinc - tot_deduction + 0.5*fica + hwdpvpengain1)

qui reg ldispinc lpregovinc
keep if e(sample)

//visualize the relationship with binscatter

xtile qs=pregovinc , nq(10)

graph box dispinc, over(qs,  label(nolab)) noout  scheme(s1mono)  nolab ytitle("Net Income") 
graph export ${OutputDir}\binplot_dispinc.png, replace

